<?php
function num2str($num) 
{
	if(strval(intval($num)) != $num)
	{
		return $num;
	}
	for( $i = 0; $num != 0; $i++ )
	{
		$j = $num % 52;
		if($j < 26)
		{
			$str = chr( $j + 97 ) . $str;
		}
		else
		{
			$str = chr( $j + 39 ) . $str;
		}
		$num = intval($num / 52);
	}
	return $str;
}

function str2num($str)
{
	if(strval(intval($str)) == $str)
	{
		return $str;
	}
	$num = 0;
	for( $i = 0; $i < strlen($str); $i++ )
	{
		$j = ord(substr( $str, $i, 1));
		if( $j < 97 )
		{
			$num = $num * 52 + ( $j - 39 );
		}
		else
		{
			$num = $num * 52 + ( $j - 97 );
		}
	}
	return $num;
}
